package com.lbn.monitor.app.history;

import android.text.TextUtils;

import com.free.framework.business.NetSubscriber;
import com.lbn.monitor.api.AppHost;
import com.lbn.monitor.api.model.RealTimeValue;
import com.lbn.monitor.base.AppBasePresenter;

import java.util.List;

/**
 * @author 李炳南
 * @date 2017/3/6
 */
public class HistoryPresenter extends AppBasePresenter<IHistoryView> {


    public void history(String mn,String dataCn, String start_time, String end_time, final int page){


        subscribeNetwork(AppHost.getApi().history(mn,dataCn, start_time, end_time, page, "20"), new NetSubscriber<List<RealTimeValue>>(getView(),false) {
            @Override
            public void onNext(List<RealTimeValue> o) {
                if(page==1){
                    getView().refreshComplete(o);
                }else{
                    getView().addMoreData(o,!(o==null||o.size()<20));
                }
            }
        });

    }

}
